package com.hundsun.yr.universal.p2p.ui.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.library.adapter.HolderAdapter;
import com.hundsun.yr.universal.library.adapter.ViewCreatorHelper;
import com.hundsun.yr.universal.library.adapter.ViewCreatorHelper.UpdateItem;
import com.hundsun.yr.universal.library.eventbus.EventCenter;
import com.hundsun.yr.universal.library.utils.SpannableStringBuilderUtils;
import com.hundsun.yr.universal.library.view.hsdialog.HSDialog;
import com.hundsun.yr.universal.library.widget.HSButton;
import com.hundsun.yr.universal.library.widget.HSLoadMoreListView;
import com.hundsun.yr.universal.library.widget.HSLoadMoreListView.OnLoadMoreListener;
import com.hundsun.yr.universal.library.widget.HSSwipeRefreshLayout;
import com.hundsun.yr.universal.p2p.bean.MineTransfer;
import com.hundsun.yr.universal.p2p.bean.MyLoanListBeen;
import com.hundsun.yr.universal.p2p.bean.UserInfo;
import com.hundsun.yr.universal.p2p.config.Constants;
import com.hundsun.yr.universal.p2p.config.Extras;
import com.hundsun.yr.universal.p2p.config.TaskConstants;
import com.hundsun.yr.universal.p2p.presenter.base.RequestPresenter;
import com.hundsun.yr.universal.p2p.presenter.impl.BaseListPresenterImpl;
import com.hundsun.yr.universal.p2p.ui.activity.LoanDetailActivity;
import com.hundsun.yr.universal.p2p.ui.activity.base.BaseFragment;
import com.hundsun.yr.universal.p2p.utils.BaseRequestTool2;
import com.hundsun.yr.universal.p2p.utils.CommTool;
import com.hundsun.yr.universal.p2p.view.base.BaseListView;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


/**
 * 我的借款-待还款
 *
 * @version V1.0
 * @Title: UnreturnLoanFragment.java
 * @Description: 应该是我的借款代未还借款
 * @date 2016-1-5 下午2:51:14
 * @author:hejun.shen
 * @email:shenhj15971@hundsun.com
 * @replace author:
 * @replace date:
 */
public class UnreturnLoanFragment extends BaseFragment implements BaseListView, UpdateItem<MyLoanListBeen>, OnLoadMoreListener, OnRefreshListener, OnItemClickListener {

    private RequestPresenter mPresenter = null;
    /**
     * 当前请求索引
     **/
    private int start = 0;
    /**
     * 下拉容器
     **/
    private HSSwipeRefreshLayout hsSwipeRefreshLayout = null;
    /**
     * listview 适配器
     **/
    private HolderAdapter<MyLoanListBeen> mAdapter = null;
    /**
     * 可以加载更多的listview
     **/
    private HSLoadMoreListView lv_transferin = null;
    /**
     * 列表数据
     **/
    private List<MyLoanListBeen> data = new ArrayList<MyLoanListBeen>();
    /**
     * 撤销弹窗
     **/
    private HSDialog dialog_revoke = null;
    /**
     * 转让单据号
     **/
    private String transferVchrNo = null;
    /**
     * 撤销份额
     **/
    private String cancelNum = null;
    /**
     * 撤销索引
     **/
    private int mPosition = 0;
    /**
     * 获取zwgt格式请求时间
     **/
    private String zwgt_data;
    /**
     * 最后一条的position
     */
    private int lastVisiblePosition;
    /**
     * 最后一条position的ctime
     */
    private Long time;
    private LayoutInflater mInflater;
    private RelativeLayout headerView;

    @Override
    protected void onFirstUserVisible() {
        // TODO Auto-generated method stub
        hsSwipeRefreshLayout.setRefreshing(true);
        mPresenter = new BaseListPresenterImpl(mContext, this, MineTransfer.BASEKEY);
        zwgt_data = BaseRequestTool2.getFormatedDateString();
        mPresenter.loadingData(TaskConstants.LOAN_LIST, getString(R.string.root_url_test) + getString(R.string.api_user_test) + TaskConstants.LOAN_LIST + "?type=" + 3,
                Constants.EVENT_REFRESH_DATA, BaseRequestTool2.getHearder(mContext, TaskConstants.TASK_GET, getString(R.string.api_user_test) + TaskConstants.LOAN_LIST + "?type=" + 3,
                        sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), zwgt_data), true);
    }

    @Override
    protected void onUserVisible() {
        // TODO Auto-generated method stub

    }

    @Override
    protected void onUserInvisible() {
        // TODO Auto-generated method stub

    }

    @Override
    protected View getLoadingTargetView() {
        // TODO Auto-generated method stub
        if (hsSwipeRefreshLayout == null) {
        }
        hsSwipeRefreshLayout = (HSSwipeRefreshLayout) findView(R.id.hsSwipeRefreshLayout);
        return hsSwipeRefreshLayout;
    }

    @Override
    protected void initViewsAndEvents() {
        // TODO Auto-generated method stub
        if (mPresenter == null) {
            mPresenter = new BaseListPresenterImpl(mContext, this, "");
        }
        mPresenter.initialized();

        if (hsSwipeRefreshLayout == null) {
            hsSwipeRefreshLayout = (HSSwipeRefreshLayout) findView(R.id.hsSwipeRefreshLayout);
        }

        lv_transferin = findView(R.id.lv_unreturnloan);
        // TODO: 2017/5/8 如果布局都是的就弄成一样的布局
        ViewCreatorHelper<MyLoanListBeen> creatorHelper = new ViewCreatorHelper<MyLoanListBeen>(R.layout.item_my_loan_all, this);
        mAdapter = new HolderAdapter<MyLoanListBeen>(mContext, creatorHelper.viewCreator());

        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        headerView = (RelativeLayout) mInflater.inflate(R.layout.item_header_10dp, lv_transferin, false);
        lv_transferin.addHeaderView(headerView);

        lv_transferin.setAdapter(mAdapter);
        lv_transferin.setOnItemClickListener(this);
        hsSwipeRefreshLayout.setOnRefreshListener(this);
        lv_transferin.setOnLoadMoreListener(this);
    }


    @Override
    protected int getContentViewLayoutID() {
        // TODO Auto-generated method stub
        return R.layout.frag_unreturn_loan;
    }

    @Override
    protected void onEveComming(@SuppressWarnings("rawtypes") EventCenter eventCenter) {
        // TODO Auto-generated method stub
    }

    @Override
    protected boolean isBindEventBusHere() {
        // TODO Auto-generated method stub
        return false;
    }

    @SuppressWarnings("unchecked")
    @Override
    public <T> void refreshListData(List<T> result) {
        // TODO Auto-generated method stub
        hsSwipeRefreshLayout.setRefreshing(false);
        lv_transferin.setLoadMoreEnabled(true);
        if (data.size() > 0) data.clear();
        if (result != null) {
            data.addAll((Collection<? extends MyLoanListBeen>) result);
        }
        mAdapter.update(data);
    }

    @SuppressWarnings("unchecked")
    @Override
    public <T> void addMoreListData(List<T> result) {
        // TODO Auto-generated method stub
        lv_transferin.onLoadMoreComplete();

        if (result != null && result.size() > 0) {
            data.addAll((Collection<? extends MyLoanListBeen>) result);
            lv_transferin.setLoadMoreEnabled(true);
        } else {
            lv_transferin.setLoadMoreEnabled(false);
        }
        mAdapter.update(data);
    }

    @Override
    public <T> void onFailure(String task_name) {
        // TODO Auto-generated method stub
        hsSwipeRefreshLayout.setRefreshing(false);
        lv_transferin.onLoadMoreComplete();
//		if(data.size() > 0) data.clear();
//		lv_transferin.setAdapter(mAdapter);
//		mAdapter.update(data);
    }

    @Override
    public void refreshItem(View view, final int position, final MyLoanListBeen invest) {
        /**还款利率**/
        TextView tv_annualincome = findView(view, R.id.tv_annualincome);
        if (!invest.debt_rate.isEmpty()) {
            tv_annualincome.setText(CommTool.keep1Digits(new BigDecimal(invest.debt_rate)) + "%");
        } else {
            tv_annualincome.setText(CommTool.keep1Digits(new BigDecimal(0)) + "%");
        }

        /**营销商品名称**/
        TextView tv_title = findView(view, R.id.tv_title);
        if (invest.prdname != null && !invest.prdname.isEmpty()) {
            tv_title.setText(invest.prdname);
        } else {
            tv_title.setText("申请编号" + invest.uuid);
        }

        /**募集总额|申请金额**/
        TextView tv_income = findView(view, R.id.tv_income);
        tv_income.setText(SpannableStringBuilderUtils.sizeSpan(getString(R.string._yuan, CommTool.keep2Digits(invest.true_debt)), getString(R.string.yuan), 12));

        /**募集状态**/
        TextView tv_prd_progress = findView(view, R.id.tv_prd_progress);
        tv_prd_progress.setText(invest.getPrdprogress());

        /**还款方式  右下**/
        TextView tv_incomemonet = findView(view, R.id.tv_incomemonet);
        tv_incomemonet.setText(invest.getPayMethod(mContext));

        /**下一期还款额度  右下**/
        TextView tv_next_amount = findView(view, R.id.tv_next_amount);

        /**撤销按钮  右中**/
        HSButton btn_cancel = findView(view, R.id.btn_prd_progress);

        /**募集总额|申请金额  中**/
        TextView tv_raise_amount = findView(view, R.id.tv_raise_amount);

        /**还款进度|借款期限  左下**/
        TextView tv_invset_money = findView(view, R.id.tv_invset_money);

        /**下期还款  右下  偏上**/
        TextView tv_next_term = findView(view, R.id.tv_next_term);

        /**
         * 0	用户草稿
         1	一审（风控）审批中
         2	二审（运营）审批中
         10	审批完成，已转产品。
         100	用户撤回
         110	一审（风控）拒绝
         120	二审（运营）拒绝
         */
        if (TextUtils.equals(invest.applyprogress, "0")) {
            //用户草稿  显示：还款方式，撤销按钮，申请金额，借款期限    ；隐藏：下期还款金额，募集状态，募集总额，还款进度，下期还款日
            /**设置还款方式**/
            tv_incomemonet.setVisibility(View.VISIBLE);
            /**下期返款金额**/
            tv_next_amount.setVisibility(View.GONE);
            /**募集状态**/
            tv_prd_progress.setVisibility(View.GONE);
            /**撤销按钮**/
            btn_cancel.setVisibility(View.VISIBLE);
            /**申请金额|募集总额**/
            tv_raise_amount.setText(getString(R.string._raise_money));
            /**还款进度|借款期限**/
            SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                    (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
            tv_invset_money.setText(spaBuilder_tv_invset_money);
            /**下期还款日**/
            tv_next_term.setVisibility(View.GONE);
        } else if (TextUtils.equals(invest.applyprogress, "1")) {
            //风控审批中 显示还款方式，撤销按钮，申请金额，借款期限    ；隐藏：下期还款金额，募集状态，募集总额，还款进度，下期还款日
            /**设置还款方式**/
            tv_incomemonet.setVisibility(View.VISIBLE);
//            tv_incomemonet.setText(invest.getPayMethod(mContext));
            /**下期返款金额**/
            tv_next_amount.setVisibility(View.GONE);
            /**募集状态**/
            tv_prd_progress.setVisibility(View.GONE);
            /**撤销按钮**/
            btn_cancel.setVisibility(View.VISIBLE);
            /**申请金额|募集总额**/
            tv_raise_amount.setText(getString(R.string._raise_money));
            /**还款进度|借款期限**/
            SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                    (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
            tv_invset_money.setText(spaBuilder_tv_invset_money);
            /**下期还款日**/
            tv_next_term.setVisibility(View.GONE);
        } else if (TextUtils.equals(invest.applyprogress, "2")) {
            //运营审批中  显示还款方式，申请金额，借款期限    ；隐藏：下期还款金额，募集状态，撤销按钮，募集总额，还款进度，下期还款日
            /**设置还款方式**/
            tv_incomemonet.setVisibility(View.VISIBLE);
//            tv_incomemonet.setText(invest.getPayMethod(mContext));
            /**下期返款金额**/
            tv_next_amount.setVisibility(View.GONE);
            /**募集状态**/
            tv_prd_progress.setVisibility(View.GONE);
            /**撤销按钮**/
            btn_cancel.setVisibility(View.GONE);
            /**申请金额|募集总额**/
            tv_raise_amount.setText(getString(R.string._raise_money));
            /**还款进度|借款期限**/
            SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                    (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
            tv_invset_money.setText(spaBuilder_tv_invset_money);
            /**下期还款日**/
            tv_next_term.setVisibility(View.GONE);
        } else if (TextUtils.equals(invest.applyprogress, "10")) {
            //审批完成，已经转为产品  显示还款进度，募集总额，显示还款状态，下期还款时间，下期还款金额；   隐藏：还款方式，撤销按钮，申请金额，借款期限
            /**设置还款方式**/
            tv_incomemonet.setVisibility(View.GONE);
            /**下期返款金额**/
            tv_next_amount.setVisibility(View.VISIBLE);
            tv_next_amount.setText(getString(R.string.next_term_repayment, invest.next_repay_amt));

            /**下期还款日**/
            tv_next_term.setVisibility(View.VISIBLE);
            tv_next_term.setText(getString(R.string.next_term, invest.next_repay_day));

            /**募集状态**/
            tv_prd_progress.setVisibility(View.VISIBLE);
            //根据不同的募集状态，对ui进行相应的改变]

            /**  50和小于20的
             * 0	未发布	0：未发布
             10	投标中	1：投标中
             15	待放款	无
             18	放款中	无
             20	计息中	2：计息中
             30	待返还（暂时不用）	3：待返还
             40	已返还	4：已返还
             50	已结束	5：已结束
             60	已撤销	6：已结束
             100	逾期未返还
             105	逾期部分返还（暂不开发）
             110	逾期已返还
             120	流标
             125	停售（募集期截止但未募满）
             130	风控拒绝放款
             200	逾期已返还(与11重复废弃)
             */
            if (TextUtils.equals(invest.prdprogress, "0")) {
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                tv_incomemonet.setVisibility(View.VISIBLE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "10")) {
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                tv_incomemonet.setVisibility(View.VISIBLE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "15")) {
                //待放款
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                tv_incomemonet.setVisibility(View.VISIBLE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
//                tv_incomemonet.setText(invest.getPayMethod(mContext));
            } else if (TextUtils.equals(invest.prdprogress, "18")) {
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                tv_incomemonet.setVisibility(View.VISIBLE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "20")) {
                //区分出还款方式1然后进行显示

                // 计息中--待还款
                tv_next_amount.setVisibility(View.VISIBLE);
                SpannableStringBuilder spaBuilder_tv_next_amount = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string.expire_time_, invest.next_repay_day), invest.next_repay_day, mContext.getResources().getColor(R.color.cl_redformula_text_3837)));
                tv_next_amount.setText(spaBuilder_tv_next_amount);
                tv_next_term.setVisibility(View.GONE);
//				tv_next_term.setText(getString(R.string.next_term,invest.next_repay_day));
                tv_incomemonet.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string.expire_repay_, invest.next_repay_amt), invest.next_repay_amt + "元", mContext.getResources().getColor(R.color.cl_redformula_text_3837)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "30")) {
                tv_next_amount.setVisibility(View.VISIBLE);
                SpannableStringBuilder spaBuilder_tv_next_amount = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string.expire_time_, invest.next_repay_day), invest.next_repay_day, mContext.getResources().getColor(R.color.cl_redformula_text_3837)));
                tv_next_amount.setText(spaBuilder_tv_next_amount);
                tv_next_term.setVisibility(View.GONE);
                tv_incomemonet.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string.expire_repay_, invest.next_repay_amt), invest.next_repay_amt + "元", mContext.getResources().getColor(R.color.cl_redformula_text_3837)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "40")) {
                //区分出还款方式1然后进行显示
                tv_next_amount.setVisibility(View.VISIBLE);
                SpannableStringBuilder spaBuilder_tv_next_amount = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string.expire_time_, invest.next_repay_day), invest.next_repay_day, mContext.getResources().getColor(R.color.cl_redformula_text_3837)));
                tv_next_amount.setText(spaBuilder_tv_next_amount);
                tv_next_term.setVisibility(View.GONE);
                tv_incomemonet.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string.expire_repay_, invest.next_repay_amt), invest.next_repay_amt + "元", mContext.getResources().getColor(R.color.cl_redformula_text_3837)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "50")) {
                //已结束
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                tv_incomemonet.setVisibility(View.VISIBLE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
//                tv_incomemonet.setText(invest.getPayMethod(mContext));
            } else if (TextUtils.equals(invest.prdprogress, "60")) {

            } else if (TextUtils.equals(invest.prdprogress, "100")) {
                // TODO: 2017/6/29
                tv_incomemonet.setVisibility(View.VISIBLE);
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "110")) {
                // TODO: 2017/6/29
                tv_incomemonet.setVisibility(View.VISIBLE);
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "105")) {
                tv_incomemonet.setVisibility(View.VISIBLE);
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "120")) {
                tv_incomemonet.setVisibility(View.VISIBLE);
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "125")) {
                tv_incomemonet.setVisibility(View.VISIBLE);
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "130")) {
                tv_incomemonet.setVisibility(View.VISIBLE);
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else if (TextUtils.equals(invest.prdprogress, "200")) {
                tv_incomemonet.setVisibility(View.VISIBLE);
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            } else {
                tv_incomemonet.setVisibility(View.VISIBLE);
                tv_next_amount.setVisibility(View.GONE);
                tv_next_term.setVisibility(View.GONE);
                SpannableStringBuilder spaBuilder_tv_invset_money = (SpannableStringBuilderUtils.colorSpan
                        (getString(R.string._term_dialog_title, invest.getTerm()), invest.getTerm(), mContext.getResources().getColor(R.color.black)));
                tv_invset_money.setText(spaBuilder_tv_invset_money);
            }
            /**撤销按钮**/
            btn_cancel.setVisibility(View.GONE);
            /**申请金额|募集总额**/
            tv_raise_amount.setText(getString(R.string._raise_totle_amount));
            /**还款进度|借款期限**/

        } else if (TextUtils.equals(invest.applyprogress, "100")) {
            //用户撤回--不会有这种状态返回

        } else if (TextUtils.equals(invest.applyprogress, "110")) {
            //一审（风控）拒绝--不会有这种状态返回

        } else {
            //二审（运营）拒绝--不会有这种状态返回
        }
    }

    @Override
    public void onLoadMore() {
        // TODO Auto-generated method stub
        zwgt_data = BaseRequestTool2.getFormatedDateString();

        lastVisiblePosition = lv_transferin.getLastVisiblePosition();
        time = Long.valueOf(data.get(lastVisiblePosition - 2).ctime);

        mPresenter.loadingData(TaskConstants.LOAN_LIST, getString(R.string.root_url_test) + getString(R.string.api_user_test) + TaskConstants.LOAN_LIST + "?type=" + 3 + "&ctime=" + time,
                Constants.EVENT_LOAD_MORE_DATA, BaseRequestTool2.getHearder(mContext, TaskConstants.TASK_GET, getString(R.string.api_user_test) + TaskConstants.LOAN_LIST + "?type=" + 3 + "&ctime=" + time,
                        sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), zwgt_data), false);
    }

    @Override
    public void onRefresh() {
        // TODO Auto-generated method stub
        zwgt_data = BaseRequestTool2.getFormatedDateString();
        mPresenter.loadingData(TaskConstants.LOAN_LIST, getString(R.string.root_url_test) + getString(R.string.api_user_test) + TaskConstants.LOAN_LIST + "?type=" + 3,
                Constants.EVENT_REFRESH_DATA, BaseRequestTool2.getHearder(mContext, TaskConstants.TASK_GET, getString(R.string.api_user_test) + TaskConstants.LOAN_LIST + "?type=" + 3,
                        sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), zwgt_data), false);
    }

    @Override
    public <T> void initializeViews(String task_name, T result) {
        // TODO Auto-generated method stub
/*		if(TextUtils.equals(task_name, TaskConstants.TASK_CANCLE)){
			data.remove(mPosition);
			mAdapter.update(data);
			showToast(R.string.revoke_success);
		}*/
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position,
                            long id) {
        if (isFastDoubleClick()) {
            return;
        }
        if (position == 0 || position > data.size()) return;
        Bundle bundle = new Bundle();
        //携带所有的数据过去
        bundle.putSerializable(Extras.DATA, data.get(position - 1));
        readyGo(LoanDetailActivity.class, bundle);
    }

    /**
     * 防止按钮连续点击
     */
    private static long lastClickTime;

    public static boolean isFastDoubleClick() {
        long time = System.currentTimeMillis();
        if (time - lastClickTime < 500) {
            return true;
        }
        lastClickTime = time;
        return false;
    }
}

